package elsa.bootmapper;

import elsa.bean.ScsLog;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface LogMapper {

    //查询日志条数(所有)
    @Select("select count(*) from scs_log where lognum = #{lognum,jdbcType=VARCHAR}")
    public int findLogCount(@Param("lognum") String lognum);

    //查询日志列表(所有)
    @Select("select logname, insptype, logtime from scs_log where lognum = #{lognum,jdbcType=VARCHAR} order by latesttime desc")
    public List<ScsLog> findAllLog(@Param("lognum") String lognum);

    //查询日志信息
    @Select("select lognum, logname, ycsname, insptype, logtime, ttime, address, logcontent, logpicture1, logpicture2, logpicture3, logpicture4," +
            " logpicture5, logpicture6, logpicture7, logpicture8, logvideo1, logvideo2 from scs_log where lognum = #{lognum,jdbcType=VARCHAR} and logtime = #{logtime,jdbcType=VARCHAR}")
    ScsLog findLogInfo(@Param("lognum") String lognum, @Param("logtime") String logtime);

    //打印日志信息
    @Select("select lognum, logname, ycsname, insptype, logtime, address, logcontent from scs_log where lognum = #{lognum,jdbcType=VARCHAR} and logtime = #{logtime,jdbcType=VARCHAR}")
    ScsLog printLogInfo(@Param("lognum") String lognum, @Param("logtime") String logtime);

    //新建日志
    @Insert("insert into scs_log (lognum, logname, ycsname, insptype, logtime, address, latesttime, ttime, logcontent, logpicture1, logpicture2, logpicture3, logpicture4, logpicture5, logpicture6, logpicture7, logpicture8, logvideo1, logvideo2) values" +
            " (#{lognum,jdbcType=VARCHAR}, #{logname,jdbcType=VARCHAR}, #{ycsname,jdbcType=VARCHAR}, #{insptype,jdbcType=VARCHAR}, #{logtime,jdbcType=VARCHAR}," +
            " #{address,jdbcType=VARCHAR}, #{latesttime}, #{ttime}, #{logcontent,jdbcType=VARCHAR}, #{logpicture1,jdbcType=VARCHAR}, #{logpicture2,jdbcType=VARCHAR}, #{logpicture3,jdbcType=VARCHAR}," +
            " #{logpicture4,jdbcType=VARCHAR}, #{logpicture5,jdbcType=VARCHAR}, #{logpicture6,jdbcType=VARCHAR}, #{logpicture7,jdbcType=VARCHAR}, #{logpicture8,jdbcType=VARCHAR}, #{logvideo1,jdbcType=VARCHAR}, #{logvideo2,jdbcType=VARCHAR})")
    void saveLog(ScsLog scslog);

    //更新日志
    @Update("update scs_log set logname = #{logname,jdbcType=VARCHAR}, logtime = #{atime,jdbcType=VARCHAR}, " +
            "address = #{address,jdbcType=VARCHAR}, latesttime = #{latesttime}, logcontent = #{logcontent,jdbcType=VARCHAR}" +
            " where lognum = #{lognum,jdbcType=VARCHAR} and logtime = #{logtime,jdbcType=VARCHAR}")
    void updateLog(ScsLog scslog);

    //删除日志(单个)
    @Delete("delete from scs_log where lognum = #{lognum,jdbcType=VARCHAR} and logtime = #{logtime,jdbcType=VARCHAR}")
    void deleteLog(@Param("lognum") String lognum, @Param("logtime") String logtime);

    //删除日志(多个)
    @Delete("delete from scs_log where lognum = #{lognum,jdbcType=VARCHAR}")
    void deleteLogAll(@Param("lognum") String lognum);
}
